<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        // // 开辟一个栈空间，里面存19
        // let age = 19
        // function fn1 (a) {
        //     // 形参也相当于是函数内的局部变量，既然是变量那一定会开空间
        //     a += 1
        // }
        // fn1 (age) 
        // console.log(age) // 19

        // let obj = { name: 'jack', age: 16 }
        // function fn2 (p) {
        //     p.name = 'rose'
        // }
        // fn2(obj)
        // console.log(obj) // { name: 'rose', age: 16 }
        /*
        let obj = { name: 'jack', age: 16 }
        function fn2 (p) {
            p = { name: 'rose', age: 19 }
        }
        fn2(obj)
        console.log(obj) // { name: 'jack', age: 16 }
        */

        // let obj = { name: '螺蛳粉', price: 99 }
        // function fn1 (a) {
        //     a += 1
        // }

        // fn1(obj.price)

        // console.log(obj) // { name: '螺蛳粉', price: 99 }

        let obj = { name: '螺蛳粉', price: 99 }
        function fn1 (a) {
            a.price += 1
        }
        fn1(obj)
        console.log(obj) // { name: '螺蛳粉', price: 100 }
    </script>
</body>
</html>